DEFTREECODE
このページを編集する際は，編集に関する方針に従ってください． 概要 *gcc-4.1.0/gcc/tree.defにて定義 例えば gcc-4.1.0/gcc/c-lang.c では， 51 /* Tree code classes. */ 52 53 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) TYPE, 54 55 const enum tree_code_class tree_code_type[] = { 56 #include "tree.def" 57 tcc_exceptional, 58 #include "c-common.def" 59 }; 60 #undef DEFTREECODE と 62 /* Table indexed by tree code giving number of expression 63 operands beyond the fixed part of the node structure. 64 Not used for types or decls. */ 65 66 #define DEFTREECODE(SYM, NAME, TYPE, LENGTH) LENGTH, 67 68 const unsigned char tree_code_length[] = { 69 #include "tree.def" 70 0, 71 #include "c-common.def" 72 }; 73 #undef DEFTREECODE と 75 /* Names of tree components. 76 Used for printing out the tree and error messages. */ 77 #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, 78 79 const char *const tree_code_name[] = { 80 #include "tree.def" 81 "@@dummy", 82 #include "c-common.def" 83 }; 84 #undef DEFTREECODE において，配列の初期化ブロック内部でインクルードされ，使われている． すなわち，tree.def がインクルードされた後，対応した引数だけがマクロで置換されて残る，というトリックが使われている． 例えば DEFTREECODE (ERROR_MARK, "error_mark", tcc_exceptional, 0) は， #define DEFTREECODE(SYM, NAME, TYPE, LEN) SYM, から #undef DEFTREEDCODE までのブロックにおいては， ERROR_MARK, に (おそらくこれは，gcc-4.1.0/gcc/tree.h 内の enum tree_index 内の要素 TI_ERROR_MARK のことだと思う)． #define DEFTREECODE(SYM, NAME, TYPE, LEN) NAME, から #undef DEFTREEDCODE までのブロックにおいては， "error_mark", に． #define DEFTREECODE(SYM, NAME, TYPE, LEN) TYPE, から #undef DEFTREEDCODE までのブロックにおいては， tcc_exceptional, に． #define DEFTREECODE(SYM, NAME, TYPE, LEN) LEN, から #undef DEFTREEDCODE までのブロックにおいては， 0, に置換され，配列の初期化の際の定数や名前として用いられることになる． SYM は，enum の要素，NAME は文字列，TYPE は種類，LEN は引数の数を表しているらしい (例えば for は for(i = 0; i < HOGESIZE; i++) などの 3 つと，ブロックの，計 4 引数らしい)． http://d.hatena.ne.jp/shinichiro_h/20040502#p1 実装 DEFTREECODE (ERROR_MARK, "error_mark", tcc_exceptional, 0) DEFTREECODE (IDENTIFIER_NODE, "identifier_node", tcc_exceptional, 0) DEFTREECODE (TREE_LIST, "tree_list", tcc_exceptional, 0) DEFTREECODE (TREE_VEC, "tree_vec", tcc_exceptional, 0) DEFTREECODE (BLOCK, "block", tcc_exceptional, 0) /* この Wiki の仕様で置換されてしまいますが，ピリオド (ドット，(.)) がソースコード中にはあります */ . DEFTREECODE (OFFSET_TYPE, "offset_type", tcc_type, 0) DEFTREECODE (ENUMERAL_TYPE, "enumeral_type", tcc_type, 0) DEFTREECODE (BOOLEAN_TYPE, "boolean_type", tcc_type, 0) DEFTREECODE (CHAR_TYPE, "char_type", tcc_type, 0) DEFTREECODE (INTEGER_TYPE, "integer_type", tcc_type, 0) DEFTREECODE (REAL_TYPE, "real_type", tcc_type, 0) DEFTREECODE (POINTER_TYPE, "pointer_type", tcc_type, 0) DEFTREECODE (REFERENCE_TYPE, "reference_type", tcc_type, 0) DEFTREECODE (COMPLEX_TYPE, "complex_type", tcc_type, 0) DEFTREECODE (VECTOR_TYPE, "vector_type", tcc_type, 0) DEFTREECODE (ARRAY_TYPE, "array_type", tcc_type, 0) DEFTREECODE (RECORD_TYPE, "record_type", tcc_type, 0) DEFTREECODE (UNION_TYPE, "union_type", tcc_type, 0) /* C union type */ DEFTREECODE (QUAL_UNION_TYPE, "qual_union_type", tcc_type, 0) DEFTREECODE (VOID_TYPE, "void_type", tcc_type, 0) DEFTREECODE (FUNCTION_TYPE, "function_type", tcc_type, 0) DEFTREECODE (METHOD_TYPE, "method_type", tcc_type, 0) DEFTREECODE (LANG_TYPE, "lang_type", tcc_type, 0) /* Wiki では置換されてしまうが，ドット (.) がある */. DEFTREECODE (INTEGER_CST, "integer_cst", tcc_constant, 0) DEFTREECODE (REAL_CST, "real_cst", tcc_constant, 0) DEFTREECODE (COMPLEX_CST, "complex_cst", tcc_constant, 0) DEFTREECODE (VECTOR_CST, "vector_cst", tcc_constant, 0) DEFTREECODE (STRING_CST, "string_cst", tcc_constant, 0) DEFTREECODE (FUNCTION_DECL, "function_decl", tcc_declaration, 0) DEFTREECODE (LABEL_DECL, "label_decl", tcc_declaration, 0) DEFTREECODE (FIELD_DECL, "field_decl", tcc_declaration, 0) DEFTREECODE (VAR_DECL, "var_decl", tcc_declaration, 0) DEFTREECODE (CONST_DECL, "const_decl", tcc_declaration, 0) DEFTREECODE (PARM_DECL, "parm_decl", tcc_declaration, 0) DEFTREECODE (TYPE_DECL, "type_decl", tcc_declaration, 0) DEFTREECODE (RESULT_DECL, "result_decl", tcc_declaration, 0) DEFTREECODE (NAMESPACE_DECL, "namespace_decl", tcc_declaration, 0) DEFTREECODE (TRANSLATION_UNIT_DECL, "translation_unit_decl",\ tcc_declaration, 0) /* ドットがある */. DEFTREECODE (COMPONENT_REF, "component_ref", tcc_reference, 3) DEFTREECODE (BIT_FIELD_REF, "bit_field_ref", tcc_reference, 3) DEFTREECODE (INDIRECT_REF, "indirect_ref", tcc_reference, 1) DEFTREECODE (ALIGN_INDIRECT_REF, "align_indirect_ref", tcc_reference, 1) DEFTREECODE (MISALIGNED_INDIRECT_REF, "misaligned_indirect_ref", tcc_reference, 2) DEFTREECODE (ARRAY_REF, "array_ref", tcc_reference, 4) DEFTREECODE (ARRAY_RANGE_REF, "array_range_ref", tcc_reference, 4) DEFTREECODE (OBJ_TYPE_REF, "obj_type_ref", tcc_expression, 3) DEFTREECODE (EXC_PTR_EXPR, "exc_ptr_expr", tcc_expression, 0) DEFTREECODE (FILTER_EXPR, "filter_expr", tcc_expression, 0) DEFTREECODE (CONSTRUCTOR, "constructor", tcc_exceptional, 0) DEFTREECODE (COMPOUND_EXPR, "compound_expr", tcc_expression, 2) DEFTREECODE (MODIFY_EXPR, "modify_expr", tcc_expression, 2) DEFTREECODE (INIT_EXPR, "init_expr", tcc_expression, 2) DEFTREECODE (TARGET_EXPR, "target_expr", tcc_expression, 4) DEFTREECODE (COND_EXPR, "cond_expr", tcc_expression, 3) DEFTREECODE (VEC_COND_EXPR, "vec_cond_expr", tcc_expression, 3) DEFTREECODE (BIND_EXPR, "bind_expr", tcc_expression, 3) DEFTREECODE (CALL_EXPR, "call_expr", tcc_expression, 3) DEFTREECODE (WITH_CLEANUP_EXPR, "with_cleanup_expr", tcc_expression, 1) DEFTREECODE (CLEANUP_POINT_EXPR, "cleanup_point_expr", tcc_expression, 1) DEFTREECODE (PLACEHOLDER_EXPR, "placeholder_expr", tcc_exceptional, 0) DEFTREECODE (PLUS_EXPR, "plus_expr", tcc_binary, 2) DEFTREECODE (MINUS_EXPR, "minus_expr", tcc_binary, 2) DEFTREECODE (MULT_EXPR, "mult_expr", tcc_binary, 2) DEFTREECODE (TRUNC_DIV_EXPR, "trunc_div_expr", tcc_binary, 2) DEFTREECODE (CEIL_DIV_EXPR, "ceil_div_expr", tcc_binary, 2) DEFTREECODE (FLOOR_DIV_EXPR, "floor_div_expr", tcc_binary, 2) DEFTREECODE (ROUND_DIV_EXPR, "round_div_expr", tcc_binary, 2) DEFTREECODE (TRUNC_MOD_EXPR, "trunc_mod_expr", tcc_binary, 2) DEFTREECODE (CEIL_MOD_EXPR, "ceil_mod_expr", tcc_binary, 2) DEFTREECODE (FLOOR_MOD_EXPR, "floor_mod_expr", tcc_binary, 2) DEFTREECODE (ROUND_MOD_EXPR, "round_mod_expr", tcc_binary, 2) DEFTREECODE (RDIV_EXPR, "rdiv_expr", tcc_binary, 2) DEFTREECODE (EXACT_DIV_EXPR, "exact_div_expr", tcc_binary, 2) DEFTREECODE (FIX_TRUNC_EXPR, "fix_trunc_expr", tcc_unary, 1) DEFTREECODE (FIX_CEIL_EXPR, "fix_ceil_expr", tcc_unary, 1) DEFTREECODE (FIX_FLOOR_EXPR, "fix_floor_expr", tcc_unary, 1) DEFTREECODE (FIX_ROUND_EXPR, "fix_round_expr", tcc_unary, 1) DEFTREECODE (FLOAT_EXPR, "float_expr", tcc_unary, 1) DEFTREECODE (NEGATE_EXPR, "negate_expr", tcc_unary, 1) DEFTREECODE (MIN_EXPR, "min_expr", tcc_binary, 2) DEFTREECODE (MAX_EXPR, "max_expr", tcc_binary, 2) DEFTREECODE (ABS_EXPR, "abs_expr", tcc_unary, 1) DEFTREECODE (LSHIFT_EXPR, "lshift_expr", tcc_binary, 2) DEFTREECODE (RSHIFT_EXPR, "rshift_expr", tcc_binary, 2) DEFTREECODE (LROTATE_EXPR, "lrotate_expr", tcc_binary, 2) DEFTREECODE (RROTATE_EXPR, "rrotate_expr", tcc_binary, 2) DEFTREECODE (BIT_IOR_EXPR, "bit_ior_expr", tcc_binary, 2) DEFTREECODE (BIT_XOR_EXPR, "bit_xor_expr", tcc_binary, 2) DEFTREECODE (BIT_AND_EXPR, "bit_and_expr", tcc_binary, 2) DEFTREECODE (BIT_NOT_EXPR, "bit_not_expr", tcc_unary, 1) DEFTREECODE (TRUTH_ANDIF_EXPR, "truth_andif_expr", tcc_expression, 2) DEFTREECODE (TRUTH_ORIF_EXPR, "truth_orif_expr", tcc_expression, 2) DEFTREECODE (TRUTH_AND_EXPR, "truth_and_expr", tcc_expression, 2) DEFTREECODE (TRUTH_OR_EXPR, "truth_or_expr", tcc_expression, 2) DEFTREECODE (TRUTH_XOR_EXPR, "truth_xor_expr", tcc_expression, 2) DEFTREECODE (TRUTH_NOT_EXPR, "truth_not_expr", tcc_expression, 1) DEFTREECODE (LT_EXPR, "lt_expr", tcc_comparison, 2) DEFTREECODE (LE_EXPR, "le_expr", tcc_comparison, 2) DEFTREECODE (GT_EXPR, "gt_expr", tcc_comparison, 2) DEFTREECODE (GE_EXPR, "ge_expr", tcc_comparison, 2) DEFTREECODE (EQ_EXPR, "eq_expr", tcc_comparison, 2) DEFTREECODE (NE_EXPR, "ne_expr", tcc_comparison, 2) DEFTREECODE (UNORDERED_EXPR, "unordered_expr", tcc_comparison, 2) DEFTREECODE (ORDERED_EXPR, "ordered_expr", tcc_comparison, 2) DEFTREECODE (UNLT_EXPR, "unlt_expr", tcc_comparison, 2) DEFTREECODE (UNLE_EXPR, "unle_expr", tcc_comparison, 2) DEFTREECODE (UNGT_EXPR, "ungt_expr", tcc_comparison, 2) DEFTREECODE (UNGE_EXPR, "unge_expr", tcc_comparison, 2) DEFTREECODE (UNEQ_EXPR, "uneq_expr", tcc_comparison, 2) DEFTREECODE (LTGT_EXPR, "ltgt_expr", tcc_comparison, 2) DEFTREECODE (RANGE_EXPR, "range_expr", tcc_binary, 2) DEFTREECODE (CONVERT_EXPR, "convert_expr", tcc_unary, 1) DEFTREECODE (NOP_EXPR, "nop_expr", tcc_unary, 1) DEFTREECODE (NON_LVALUE_EXPR, "non_lvalue_expr", tcc_unary, 1) DEFTREECODE (VIEW_CONVERT_EXPR, "view_convert_expr", tcc_reference, 1) DEFTREECODE (SAVE_EXPR, "save_expr", tcc_expression, 1) DEFTREECODE (ADDR_EXPR, "addr_expr", tcc_expression, 1) DEFTREECODE (FDESC_EXPR, "fdesc_expr", tcc_expression, 2) DEFTREECODE (COMPLEX_EXPR, "complex_expr", tcc_binary, 2) DEFTREECODE (CONJ_EXPR, "conj_expr", tcc_unary, 1) DEFTREECODE (REALPART_EXPR, "realpart_expr", tcc_reference, 1) DEFTREECODE (IMAGPART_EXPR, "imagpart_expr", tcc_reference, 1) DEFTREECODE (PREDECREMENT_EXPR, "predecrement_expr", tcc_expression, 2) DEFTREECODE (PREINCREMENT_EXPR, "preincrement_expr", tcc_expression, 2) DEFTREECODE (POSTDECREMENT_EXPR, "postdecrement_expr", tcc_expression, 2) DEFTREECODE (POSTINCREMENT_EXPR, "postincrement_expr", tcc_expression, 2) DEFTREECODE (VA_ARG_EXPR, "va_arg_expr", tcc_expression, 1) DEFTREECODE (TRY_CATCH_EXPR, "try_catch_expr", tcc_statement, 2) DEFTREECODE (TRY_FINALLY_EXPR, "try_finally", tcc_statement, 2) /* ドット */. DEFTREECODE (DECL_EXPR, "decl_expr", tcc_statement, 1) DEFTREECODE (LABEL_EXPR, "label_expr", tcc_statement, 1) DEFTREECODE (GOTO_EXPR, "goto_expr", tcc_statement, 1) DEFTREECODE (RETURN_EXPR, "return_expr", tcc_statement, 1) DEFTREECODE (EXIT_EXPR, "exit_expr", tcc_statement, 1) DEFTREECODE (LOOP_EXPR, "loop_expr", tcc_statement, 1) DEFTREECODE (SWITCH_EXPR, "switch_expr", tcc_statement, 3) DEFTREECODE (CASE_LABEL_EXPR, "case_label_expr", tcc_statement, 3) DEFTREECODE (RESX_EXPR, "resx_expr", tcc_statement, 1) DEFTREECODE (ASM_EXPR, "asm_expr", tcc_statement, 4) DEFTREECODE (SSA_NAME, "ssa_name", tcc_exceptional, 0) DEFTREECODE (PHI_NODE, "phi_node", tcc_exceptional, 0) DEFTREECODE (CATCH_EXPR, "catch_expr", tcc_statement, 2) DEFTREECODE (EH_FILTER_EXPR, "eh_filter_expr", tcc_statement, 2) DEFTREECODE (SCEV_KNOWN, "scev_known", tcc_expression, 0) DEFTREECODE (SCEV_NOT_KNOWN, "scev_not_known", tcc_expression, 0) DEFTREECODE (POLYNOMIAL_CHREC, "polynomial_chrec", tcc_expression, 3) DEFTREECODE (STATEMENT_LIST, "statement_list", tcc_exceptional, 0) DEFTREECODE (VALUE_HANDLE, "value_handle", tcc_exceptional, 0) DEFTREECODE (ASSERT_EXPR, "assert_expr", tcc_expression, 2) DEFTREECODE (TREE_BINFO, "tree_binfo", tcc_exceptional, 0) DEFTREECODE (WITH_SIZE_EXPR, "with_size_expr", tcc_expression, 2) DEFTREECODE (REALIGN_LOAD_EXPR, "realign_load", tcc_expression, 3) DEFTREECODE (TARGET_MEM_REF, "target_mem_ref", tcc_reference, 7) DEFTREECODE (REDUC_MAX_EXPR, "reduc_max_expr", tcc_unary, 1) DEFTREECODE (REDUC_MIN_EXPR, "reduc_min_expr", tcc_unary, 1) DEFTREECODE (REDUC_PLUS_EXPR, "reduc_plus_expr", tcc_unary, 1) DEFTREECODE (VEC_LSHIFT_EXPR, "vec_lshift_expr", tcc_binary, 2) DEFTREECODE (VEC_RSHIFT_EXPR, "vec_rshift_expr", tcc_binary, 2) 呼び出され元 #related コメント #comment *作者：あろは